﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.EShop.Common.Entity;
using Runda.EShop.Common.Utility;
using Runda.EShop.Bll;

namespace Runda.EShop.Web.UserControl
{
    public partial class OrderInfo : UserControlBase
    {
        public Guid OrderID
        {
            get
            {
                if (Request.QueryString["OrderID"] != null)
                {
                    return new Guid(Request.QueryString["OrderID"]);
                }
                return Guid.Empty;
            }
        }
        public BizOrderEntity OrderEntity
        {
            get;
            set;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BizOrderEntity entity = OrderEntity;// new OrderBll().Get<BizOrderEntity>(OrderID);
                if (entity == null) entity = new OrderBll().Get<BizOrderEntity>(OrderID);
                if (entity != null)
                {
                    ltlOrderCode.Text = entity.OrderCode;
                    ltlOrderDate.Text = entity.OrderDate.ToString();
                    EnumHelper.OrderType orderType = (EnumHelper.OrderType)entity.OrderType;
                    ltlOrderType.Text = EnumDescAttribute.GetFieldText(orderType);

                    EnumHelper.OrderStatus orderStatus = (EnumHelper.OrderStatus)entity.OrderStatus;
                    ltlOrderStatus.Text = EnumDescAttribute.GetFieldText(orderStatus);
                    ltlAddress.Text = entity.ReceiveAddr;
                    ltlName.Text = entity.ReceiveName;
                    ltlPhone.Text = entity.ReceiverPhone;
                }
            }
        }


        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.Load += new EventHandler(Page_Load);
        }
    }
}